package com.nervenets.template.controller.data.params;

import com.nervenets.general.web.params.EntityPagingParams;
import com.nervenets.template.hibernate.domain.data.DataOfGold;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.SuperBuilder;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class DataOfGoldPagingParams extends EntityPagingParams<DataOfGold> {
    @ApiModelProperty(value = "开始时间")
    private long startTime;
    @ApiModelProperty(value = "结束时间")
    private long endTime;

    @Override
    public void generateSpecification(List<Predicate> predicates, Root<DataOfGold> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
        addBetweenPredicate(root.get("createTime"), startTime, endTime);
    }
}
